package com.qrpay.model.enums;

/**
 * 交易类型
 */
public enum TxnType {

    Recharge("Recharge", "充值", "Recharge"),
    QrPay("QrPay", "二维码支付", "Payment"),
    BuyVip("BuyVip", "购买VIP", "Purchase Package"),
    UpdateVip("UpdateVip", "更改VIP", "Update Package"),
    AgentPay("AgentPay", "代付", "Agent Payment"),
    ;

    private final String code;
    private final String descCh;
    private final String descEn;

    TxnType(String code, String descCh, String descEn) {
        this.code = code;
        this.descCh = descCh;
        this.descEn = descEn;
    }

    public String getCode() {
        return code;
    }

    public String getDescCh() {
        return descCh;
    }

    public String getDescEn() {
        return descEn;
    }

    public boolean equals(String code) {
        return this.code.equals(code);
    }

    public static TxnType byCode(String code) {
        for (TxnType t : values()) {
            if (t.equals(code)) return t;
        }
        return null;
    }
}
